Skip to content

fix: Add until predicates to any listeners#1377

Open
ricardozanini wants to merge 1 commit intoserverlessworkflow:mainfrom
ricardozanini:fix/listen-all-until
Open

fix: Add until predicates to any listeners#1377
ricardozanini wants to merge 1 commit intoserverlessworkflow:mainfrom
ricardozanini:fix/listen-all-until

Conversation

@ricardozanini
Copy link
Copy Markdown
Member

Many thanks for submitting your Pull Request ❤️!

What this PR does / why we need it:

  • Added tests to validate toAny accumulation and predicate evaluation on until.
  • Enforce specification by throwing an illegal argument exception in case until is called in all or one.

Special notes for reviewers:

Additional information (if needed):

Signed-off-by: Ricardo Zanini <ricardozanini@gmail.com>
Copilot AI review requested due to automatic review settings May 8, 2026 18:55
@ricardozanini ricardozanini requested a review from fjtirado as a code owner May 8, 2026 18:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the listen DSL to support additional until(...) predicate shapes for toAny(...) listeners (plain predicate, context-aware predicate, and filter-aware predicate), and enforces the spec restriction that until is only valid with the any consumption strategy.

Changes:

  • Added strategy tracking/validation to reject until() when used with all() or one() consumption strategies.
  • Added until(ContextPredicate, Class) and until(FilterPredicate, Class) overloads to the Func listen builders/specs.
  • Added new tests covering toAny(...).until(...) predicate evaluation and validating that until with all/one throws.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
fluent/spec/src/main/java/io/serverlessworkflow/fluent/spec/dsl/BaseListenSpec.java Tracks selected listen strategy and throws if until is used with non-any strategies.
experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/FuncListenToBuilder.java Adds until overloads for context/filter predicate functional interfaces.
experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/dsl/BaseFuncListenSpec.java Adds matching until overloads at the DSL spec layer (and adds predClass null checks).
experimental/lambda/src/test/java/io/serverless/workflow/impl/executors/func/ListenUntilValidationTest.java New tests asserting until is rejected for toAll and toOne.
experimental/lambda/src/test/java/io/serverless/workflow/impl/executors/func/ListenUntilCurrentTest.java New integration tests validating toAny accumulation and the new predicate overloads.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +104 to +108
if (untilStep != null && strategyType != StrategyType.ANY) {
throw new IllegalStateException(
"until() is only supported with any() event consumption strategy. "
+ "Current strategy: "
+ strategyType);
Comment on lines +48 to +62
Objects.requireNonNull(predClass, "predClass");
this.setUntilStep(u -> u.until(predicate, predClass));
return self();
}

public <T> SELF until(ContextPredicate<T> predicate, Class<T> predClass) {
Objects.requireNonNull(predicate, "predicate");
Objects.requireNonNull(predClass, "predClass");
this.setUntilStep(u -> u.until(predicate, predClass));
return self();
}

public <T> SELF until(FilterPredicate<T> predicate, Class<T> predClass) {
Objects.requireNonNull(predicate, "predicate");
Objects.requireNonNull(predClass, "predClass");
Comment on lines +48 to +62
Objects.requireNonNull(predClass, "predClass");
this.setUntilStep(u -> u.until(predicate, predClass));
return self();
}

public <T> SELF until(ContextPredicate<T> predicate, Class<T> predClass) {
Objects.requireNonNull(predicate, "predicate");
Objects.requireNonNull(predClass, "predClass");
this.setUntilStep(u -> u.until(predicate, predClass));
return self();
}

public <T> SELF until(FilterPredicate<T> predicate, Class<T> predClass) {
Objects.requireNonNull(predicate, "predicate");
Objects.requireNonNull(predClass, "predClass");
Comment on lines +48 to +62
Objects.requireNonNull(predClass, "predClass");
this.setUntilStep(u -> u.until(predicate, predClass));
return self();
}

public <T> SELF until(ContextPredicate<T> predicate, Class<T> predClass) {
Objects.requireNonNull(predicate, "predicate");
Objects.requireNonNull(predClass, "predClass");
this.setUntilStep(u -> u.until(predicate, predClass));
return self();
}

public <T> SELF until(FilterPredicate<T> predicate, Class<T> predClass) {
Objects.requireNonNull(predicate, "predicate");
Objects.requireNonNull(predClass, "predClass");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants